import { request, download } from '@/request.js'
import { API } from '@/api.js'
import { BASE_URL } from '@/const.js'

export function login(data) {
	return request({
		url: API.login,
		needAuth: false,
		method: "POST",
		data
	})
}

export function loginWithPwd(data) {
	return request({
		url: API.loginWithPwd,
		needAuth: false,
		method: "POST",
		data
	})
}

export function updatePhone(data) {
	return request({
		url: API.updatePhone,
		method: "POST",
		data
	})
}

export function getUserDetail(data) {
	return request({
		url: API.getUserDetail,
		data
	})
}

export function getMembersByIds(data) {
	return request({
		url: API.getMembersByIds,
		method: "POST",
		data
	})
}

export function getVipCards() {
	return request({
		url: API.getVipCards,
		needAuth: false,
	})
}

export function genOrder(data) {
	return request({
		url: API.genOrder,
		data
	})
}

export function genOrderPayInfo(orderId) {
	return request({
		url: API.genOrderPayInfo,
		data: {
			orderId: orderId
		}
	})
}

export function queryOrderStatus(orderSn) {
	return request({
		url: API.queryOrderStatus,
		data: {
			orderSn: orderSn
		}
	})
}

export function getTickets(data) {
	return request({
		url: API.getTickets,
		data
	})
}

export function getTicketDetail(id) {
	return request({
		url: API.getTicketDetail + "/" + id,
	})
}

export function getShops(data) {
	return request({
		url: API.getShops,
		needAuth: false,
		data
	})
}

export function getGroupGoods(data) {
	return request({
		url: API.getGroupGoods,
		needAuth: false,
		data
	})
}

export function getCurrGroupMembers(groupId, showLoading) {
	return request({
		url: API.getCurrGroupMembers,
		needAuth: false,
		showLoading: showLoading,
		data: { groupId }
	})
}

export function getGoodsByIds(data) {
	return request({
		url: API.getGoodsByIds,
		needAuth: false,
		method: "POST",
		data
	})
}

export function getGoodsDetail(id) {
	return request({
		url: API.getGoodsDetail + '/' + id,
		needAuth: false,
	})
}

export function getServiceList(data) {
	return request({
		url: API.getServiceList,
		needAuth: false,
		data
	})
}

export function getAllServiceList(data) {
	return request({
		url: API.getAllServiceList,
		needAuth: false,
		data
	})
}

export function getRemainServiceTimes(data) {
	return request({
		url: API.getRemainServiceTimes,
		method: "POST",
		data
	})
}

export function getGroupDetail(id) {
	return request({
		url: API.getGroupDetail + '/' + id,
		needAuth: false,
	})
}

export function getGroupMemberDetail(id, showLoading) {
	return request({
		url: API.getGroupMemberDetail + '/' + id,
		needAuth: false,
		showLoading: showLoading
	})
}

export function getGroupMember(groupId) {
	return request({
		url: API.getGroupMember,
		data: {
			groupId: groupId
		}
	})
}

export function cancelGroupMember(groupMemberId) {
	return request({
		url: API.cancelGroupMember,
		data: {
			groupMemberId: groupMemberId
		}
	})
}

export function getOrders(data) {
	return request({
		url: API.getOrders,
		data
	})
}

export function getOrderDetail(id) {
	return request({
		url: API.getOrderDetail,
		data: {
			id: id
		}
	})
}

export function getVipCardDetail(level) {
	return request({
		url: API.getVipCardDetail,
		data: {
			level: level
		}
	})
}

export function getServiceCategorys(data) {
	return request({
		url: API.getServiceCategorys,
		needAuth: false,
		data
	})
}

export function getServiceCount(data) {
	return request({
		url: API.getServiceCount,
		needAuth: false,
		data
	})
}

export function getServiceRecommends(data) {
	return request({
		url: API.getServiceRecommends,
		needAuth: false,
		data
	})
}

export function getStoreDetail(id, data) {
	return request({
		url: API.getStoreDetail + "/" + id,
		needAuth: false,
		data
	})
}

export function getBalanceDetail(data) {
	return request({
		url: API.getBalanceDetail,
		data
	})
}

export function applyDeposit(amount) {
	return request({
		url: API.applyDeposit,
		data: {
			amount: amount
		}
	})
}

export function getBannerList(type) {
	return request({
		url: API.getBannerList,
		needAuth: false,
		data: {
			type: type
		}
	})
}
export function getBannerDetail(id) {
	return request({
		url: `${API.getBannerDetail}/${id}`,
		needAuth: false,
	})
}

export function commitAuth(data) {
	return request({
		url: API.commitAuth,
		method: 'post',
		data
	})
}

export function queryAuth() {
	return request({
		url: API.queryAuth,
	})
}

export function getAuth() {
	return request({
		url: API.getAuth,
	})
}
